﻿using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;

namespace Foundation
{
    /// <summary>
    /// A toggle button which don't get focus when pressed.
    /// </summary>
    public class SimpleToggleButton : ToggleButton
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleToggleButton"/> class.
        /// </summary>
        public SimpleToggleButton()
        {
            IInputElement control = null;
            PreviewGotKeyboardFocus += delegate
                { control = Keyboard.FocusedElement; };
            GotFocus += delegate
                {
                    if (control != null)
                    {
                        control.Focus();
                    }
                };
        }
    }
}
